package com.kis.pattern.proxy.dy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * Created by yks on 15-11-24.
 */
public class SomeHandler implements InvocationHandler{
    private Object object;

    public Object bind(Object object){
        this.object = object;
        System.out.println(object.getClass().getInterfaces()[0]);
        return Proxy.newProxyInstance(object.getClass().getClassLoader(),object.getClass().getInterfaces(),this);
    }
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object result = null;
        System.out.println("调用方法之前");
        result = method.invoke(object,args);
        System.out.println("调用方法之后");
        return result;

    }
}
